package by.amakarevich.datamodel;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapsId;
import javax.persistence.OneToOne;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity
public class DeliveryAddress implements Serializable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	@Column
	@NotNull
	@Size(max=200)
	private String city;
	
	@Column
	@NotNull
	@Size(max=200)
	private String street;
	
	@Column
	@NotNull
	@Size(max=200)
	private String house;
	
	@Column
	@Size(max=200)
	private String apartment;
	
	@Column
	@NotNull
	private Long contactPhone;
	
	@Column
	@NotNull
	@Size(max=200)
	private String contactPersonName;
	
	@Column
	@NotNull
	@Size(max=200)
	private String contactPersonLastName;
	
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserAccount.class)
	@JoinColumn(name = "user_account_id", nullable = false)
	private UserAccount userAccount;
	
	@MapsId
	@OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE }, targetEntity = Booking.class)
	@JoinColumn(updatable = false, name = "id")
	private Booking booking;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getStreet() {
		return street;
	}
	public void setStreet(String street) {
		this.street = street;
	}
	public String getHouse() {
		return house;
	}
	public void setHouse(String house) {
		this.house = house;
	}
	public String getApartment() {
		return apartment;
	}
	public void setApartment(String apartment) {
		this.apartment = apartment;
	}
	public Long getContactPhone() {
		return contactPhone;
	}
	public void setContactPhone(Long contactPhone) {
		this.contactPhone = contactPhone;
	}
	public String getContactPersonName() {
		return contactPersonName;
	}
	public void setContactPersonName(String contactPersonName) {
		this.contactPersonName = contactPersonName;
	}
	public String getContactPersonLastName() {
		return contactPersonLastName;
	}
	public void setContactPersonLastName(String contactPersonLastName) {
		this.contactPersonLastName = contactPersonLastName;
	}
	public UserAccount getUserAccount() {
		return userAccount;
	}
	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}
	public Booking getBooking() {
		return booking;
	}
	public void setBooking(Booking booking) {
		this.booking = booking;
	}
	
	
}
